package cn.iocoder.yudao.module.fm.dal.mysql.fileinfo;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fm.dal.dataobject.fileinfo.FileInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fm.controller.admin.fileinfo.vo.*;

/**
 * 文件信息 Mapper
 *
 * @author 档案
 */
@Mapper
public interface FileInfoMapper extends BaseMapperX<FileInfoDO> {

    default PageResult<FileInfoDO> selectPage(FileInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FileInfoDO>()
                .eqIfPresent(FileInfoDO::getNo, reqVO.getNo())
                .eqIfPresent(FileInfoDO::getDocumentationStage, reqVO.getDocumentationStage())
                .likeIfPresent(FileInfoDO::getFileName, reqVO.getFileName())
                .likeIfPresent(FileInfoDO::getFileName, reqVO.getKeyword())
                .eqIfPresent(FileInfoDO::getFileFormat, reqVO.getFileFormat())
                .eqIfPresent(FileInfoDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(FileInfoDO::getParentId, reqVO.getParentId())
                .eqIfPresent(FileInfoDO::getParentType, reqVO.getParentType())
                .betweenIfPresent(FileInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FileInfoDO::getId));
    }

    default List<FileInfoDO> selectList(FileInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<FileInfoDO>()
                .eqIfPresent(FileInfoDO::getNo, reqVO.getNo())
                .eqIfPresent(FileInfoDO::getDocumentationStage, reqVO.getDocumentationStage())
                .likeIfPresent(FileInfoDO::getFileName, reqVO.getFileName())
                .eqIfPresent(FileInfoDO::getFileFormat, reqVO.getFileFormat())
                .eqIfPresent(FileInfoDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(FileInfoDO::getParentId, reqVO.getParentId())
                .eqIfPresent(FileInfoDO::getParentType, reqVO.getParentType())
                .betweenIfPresent(FileInfoDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(FileInfoDO::getId));
    }

}
